package com.xujl.mvcbind.adapter;

import android.view.View;

import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.xujl.fastlib.base.BaseRvAdapter;
import com.xujl.fastlib.utils.DateUtil;
import com.xujl.fastlib.utils.ResUtils;
import com.xujl.fastlib.utils.StringUtils;
import com.xujl.mvcbind.R;
import com.xujl.mvcbind.bean.OverTimeEntity;

import java.util.List;

import androidx.annotation.Nullable;

public class OverTimeAdapter extends BaseRvAdapter<OverTimeEntity> {
    public OverTimeAdapter (@Nullable List<OverTimeEntity> data) {
        super(R.layout.item_over_time, data);
    }

    @Override
    protected void convert (BaseViewHolder helper, OverTimeEntity item) {
        helper.setText(R.id.tv_date, DateUtil.getDateToString(item.getDate(), DateUtil.Y_M_D_H_M))
                .setText(R.id.tv_duration, item.getDuration())
                .setText(R.id.tv_remark, item.getRemark())
                .setText(R.id.tv_week, DateUtil.getWeek(item.getDate()))
                .setBackgroundColor(R.id.card_view, ResUtils.getColor(OverTimeEntity.isOverTime(item.getType()) ? R.color.white : R.color.text_green));
        helper.getView(R.id.tv_remark).setVisibility(StringUtils.isEmpty(item.getRemark()) ? View.GONE : View.VISIBLE);

    }
}
